<?php
$array=[
    "key1"=> "value1",
    "key2"=> "value2",
];

$variable='key1';
echo $array[$variable];
$variable='key2';
echo $array[$variable];
